#ifndef PACKAGEBUFFER_H
#define PACKAGEBUFFER_H

#include <stdint.h>

struct PackageBuffer
{
public:
    uint8_t *pBuffer; // 数据包缓冲起始地址
    uint16_t nMaxLen; // 数据包最大长度，最大64K
    uint16_t nPkgLen; // 完整数据包需接收的总长度，最长64K
    uint16_t nCurLen; // 当前已接收数据长度

public:
    PackageBuffer();
    ~PackageBuffer();

public:
    bool Initialize(uint16_t nMaxLen);
    void Destroy();
    void Reset();

    uint8_t *WritePos() { return pBuffer + nCurLen; }
    uint16_t SpaceLen() { return nMaxLen - nCurLen; }
};

#endif // PACKAGEBUFFER_H
